package huawei;

import java.util.ArrayList;
import java.util.LinkedList;
import java.util.List;
import java.util.Scanner;

public class Main {
    public static void main(String[] args) {
        sss();
    }

    public static void sss(){
        Scanner in = new Scanner(System.in);

        ArrayList<Integer> arrayList = new ArrayList<>();

        while (in.hasNextInt()){
            arrayList.add(in.nextInt());
        }

        int min = arrayList.get(0);
        int minIndex = 0;

        for (int i = 1; i < arrayList.size(); i++){

            int currtentValue = arrayList.get(i);
            if (currtentValue < min  && currtentValue >= 0){
                minIndex = i;
                min = currtentValue;
            }
        }
        minIndex++;


        List<Integer>  indexs = new LinkedList<>();

        indexs.add(arrayList.get(minIndex - 1));

        while (minIndex > 1){
            if (minIndex % 2 > 0){
                minIndex--;
            }

            minIndex = minIndex/2;
            indexs.add(arrayList.get(minIndex - 1));
        }

        for (int i = indexs.size() - 1; i >= 0; i--){
            System.out.print(indexs.get(i) + " ");
        }

//        int level =


    }

    public static class Node{
        Node left;
        Node rigth;
        int value;
    }



    public static void laji(){
        Scanner in = new Scanner(System.in);
        long num = in.nextLong();
        int yNum = in.nextInt();

//        long num = 2601;
//        int yNum = 2;

//        System.out.println(Math.pow(2, 10));

        long charMaxNum = (long)(Math.pow(26, yNum));
//        System.out.println("字符串的最大组合数：" + charMaxNum);

        long xNum = num / charMaxNum - 1;

        int mod = (int) (num % charMaxNum);
//        System.out.println("mod:" + mod);
        if (mod != 0){
            xNum += 1;
        }

//        System.out.println("数字端最大可能性：" + xNum);

        System.out.println((xNum + "").length());

//        System.out.println("num:" + num + "  yNum:" + yNum);
//        String data = in.next();
//        System.out.println(data);
//        String[] array = data.split(" ");
//        System.out.println(array.length);
    }
}
